import com.jacob.com.*;
import com.jacob.activeX.*;

////
//Flying over Gao
//by cdriko

// SRC http://processing.org/discourse/yabb2/YaBB.pl?num=1206005015
// API http://earth.google.com/comapi/interfaceIApplicationGE.html

void setup(){
  size(1,1);
}


void draw(){

 ///definition of values  
 float tilt =10;
 float heading = 30;
 float sec=(millis()/3000.);
 float latitude=35.66+0.025*cos(sec);
 float longitude=139.66 +(0.025*sin(sec));
 float altitude=5000;

 ///call to googleEarth
 Dispatch googleEarth = new Dispatch("GoogleEarth.ApplicationGE");

 Dispatch.call(googleEarth,"SetCameraParams",new Variant(latitude),new
   Variant(longitude),new Variant(altitude),new Variant(1),new
   Variant(100),new Variant(tilt),new Variant(heading),new Variant(5));

} 
//////


/*

API description
================

HRESULT IApplicationGE::SetCameraParams  ( [in] double  lat,  
  [in] double  lon,  
  [in] double  alt,  
  [in] AltitudeModeGE  altMode,  
  [in] double  range,  
  [in] double  tilt,  
  [in] double  azimuth,  
  [in] double  speed   
 )    

Flies to the specified camera without requiring an ICameraInfoGE instance. 

This is provided for performance reasons.

This is an optimized way of setting the camera rather than using SetCamera since it requires a much smaller number of COM calls.


Parameters:
 lat  Latitude in degrees. Between -90 and 90.  
 lon  Longitude in degrees. Between -180 and 180.  
 alt  Altitude in meters.  
 altMode  Altitude mode that defines altitude reference origin.  
 range  Distance between focus point and camera in meters.  
 tilt  Tilt angle in degrees. Between 0 and 90.  
 azimuth  Azimuth angle in degrees.  
 speed  Speed factor to use. Overrides autopilot speed. Value must be greater than 0. If greater than or equal to 5.0, the camera will immediately be set without any transition. This mode is called 'teleport'. 

Return values:
 S_OK  Successfully set camera.  
 S_TELEPORTED  Given speed is grater than or equal to 5.0, in which case application's camera was teleported to the destination view.  
 E_INVALIDARG  invalid argument(s) (e.g. speed is not more than zero).  
 E_APPLICATION_UNINITIALIZED  Google Earth is not initialized. See IsInitialized.  
 (other)  Appropriate error code. 

See also:
SetCamera, ICameraInfoGE 
*/


/*

MEMO
=====


latitude 緯度 
   東京 北緯30度
   サンプル座標   35度 36分 8.55秒
longtitude 経度   
   サンプル座標   139度 46分 32.16秒
*/


